<?php
class login extends Controller{
    function login(){
        parent::Controller();
        $this->load->model('m_login');
    }
    function index(){
        if($this->session->userdata('login') == TRUE){
            redirect('Main');
        }
        else{
            $this->load->view('login/v_login');
        }
    }
    function cek_login(){
        $username = $this->input->post('username');
        $password = $this->input->post('password');
        
        $cek = $this->m_login->cek_user($username,$password);
        if($cek == FALSE){
            $this->session->set_flashdata("message",5);
            redirect("login");
        }else{
            foreach ($cek as $data);
            $this->session->set_userdata($data);
            redirect('main');
        }
    }
    function process_logout(){
        $this->session->sess_destroy();
        redirect("login","refresh");
    }
}
?>
